﻿
namespace CARE.Web.Services
{
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.ComponentModel.DataAnnotations;
    using System.Data.Linq;
    using System.Linq;
    using System.Web.DomainServices;
    using System.Web.DomainServices.Providers;
    using System.Web.Ria;
    using System.Web.Ria.Services;
    using CARE.Web.db;


    // Implements application logic using the DiseaseDataClassesDataContext context.
    // TODO: Add your application logic to these methods or in additional methods.
    // TODO: Wire up authentication (Windows/ASP.NET Forms) and uncomment the following to disable anonymous access
    // Also consider adding roles to restrict access as appropriate.
    // [RequiresAuthentication]
    [EnableClientAccess()]
    [RequiresAuthentication]
    public class DataProvider : LinqToSqlDomainService<DiseaseDataClassesDataContext>
    {

        // TODO: Consider
        // 1. Adding parameters to this method and constraining returned results, and/or
        // 2. Adding query methods taking different parameters.
        public IQueryable<Disease> GetDiseases()
        {
            return this.DataContext.Diseases;
        }

        public void InsertDisease(Disease disease)
        {
            this.DataContext.Diseases.InsertOnSubmit(disease);
        }

        public void UpdateDisease(Disease currentDisease)
        {
            this.DataContext.Diseases.Attach(currentDisease, this.ChangeSet.GetOriginal(currentDisease));
        }

        public void DeleteDisease(Disease disease)
        {
            this.DataContext.Diseases.Attach(disease);
            this.DataContext.Diseases.DeleteOnSubmit(disease);
        }

        // TODO: Consider
        // 1. Adding parameters to this method and constraining returned results, and/or
        // 2. Adding query methods taking different parameters.
        public IQueryable<Edge> GetEdges()
        {
            return this.DataContext.Edges;
        }

        // TODO: Consider
        // 1. Adding parameters to this method and constraining returned results, and/or
        // 2. Adding query methods taking different parameters.
        public IQueryable<Image> GetImages()
        {
            return this.DataContext.Images;
        }

        // TODO: Consider
        // 1. Adding parameters to this method and constraining returned results, and/or
        // 2. Adding query methods taking different parameters.
        public IQueryable<Net> GetNets()
        {
            return this.DataContext.Nets;
        }

        // TODO: Consider
        // 1. Adding parameters to this method and constraining returned results, and/or
        // 2. Adding query methods taking different parameters.
        public IQueryable<Node> GetNodes()
        {
            return this.DataContext.Nodes;
        }
    }
}


